package Functions;


/**
 * Write a description of class PayerFunctions here.
 * 
 * @author The_MHMoritz3
 * @version 1.0
 * @date 20.10.2014
 */

import net.canarymod.chat.Colors;
import net.canarymod.api.entity.living.humanoid.Player;
import net.canarymod.chat.MessageReceiver;
import net.canarymod.api.Server;

public class PlayerFunctions
{   
   public static void afk(MessageReceiver caller)
   {
        Player afkWantedplayer = (Player)caller;
        afkWantedplayer.chat(Colors.PINK + "I'm afk");
        afkWantedplayer.setInvisible(true);
        afkWantedplayer.setMuted(true);
        afkWantedplayer.setHealth(10);
   }
   
   public static void sendMessage(MessageReceiver caller, String[] args)
   {
        Player sender = (Player)caller;
        Server actualServer = (Server)caller;
        Player destination;
        String message = getMessageOfArgs(args);
        if((destination = actualServer.getPlayer(args[0]))!=null)
        {
            destination.message(Colors.TURQUIOSE + "Message From: " + sender.getName());
            destination.message(message);
            destination.message(Colors.TURQUIOSE + "Type /reply to Reply");
        }else
        {
            sender.message(Colors.TURQUIOSE + "Player is currently mot online");
            //saveMessage(String destination, String sender, String Message);
        }
   }
   
   private static String getMessageOfArgs(String[] args)
   {
       String message="";
       for(int i = 1; i<args.length; i++)
       {
           message+=args[i];
       }
       return message;
   }
    
   public static void replyOfMessage(MessageReceiver caller, String[] args)
   {
        Player sender = (Player)caller;
        Server actualServer = (Server)caller;
        Player destination;
        String message = getMessageOfArgs(args);
        if((destination = actualServer.getPlayer(args[0]))!=null)
        {
            destination.message(Colors.TURQUIOSE + "Message From: " + sender.getName());
            destination.message(message);
            destination.message(Colors.TURQUIOSE + "Type /reply to Reply");
        }else
        {
            sender.message(Colors.TURQUIOSE + "Player is currently mot online");
            //saveMessage(String destination, String sender, String Message);
        }
   }
}
